/**

 @Name：layuiAdmin 主页控制台
 @Author：贤心
 @Site：http://www.layui.com/admin/
 @License：LPPL
    
 */


layui.define(function(exports){
  
  /*
    下面通过 layui.use 分段加载不同的模块，实现不同区域的同时渲染，从而保证视图的快速呈现
  */

  //通知列表
  layui.use(['admin', 'laytpl', 'carousel', 'echarts', 'saleChart', 'numberChart', 'monthChart', 'channelChart'], function(){
    var $ = layui.$
    ,setter = layui.setter
    ,admin = layui.admin
    ,laytpl = layui.laytpl
    ,carousel = layui.carousel
    ,element = layui.element
    ,device = layui.device()
    ,saleChart = layui.saleChart
    ,numberChart = layui.numberChart
    ,monthChart = layui.monthChart
    ,channelChart = layui.channelChart;

    admin.req({
      url: setter.url + '/message/myNotifyList'
      ,type: 'GET'
      ,data: {
        page: 1,
        pageSize: 10
      }
      ,done: function (res) {
        var data = res.data || {}
        ,getTpl = $('#LAY-notify-tpl').html();

        data.list = data.list || [];

        if (!getTpl) {
          return;
        }

        laytpl(getTpl).render(data, function(html){
          $('#LAY-notify-view').html(html);
        });
      }
    });

    //轮播初始化
    $('.layadmin-carousel').each(function(){
      var othis = $(this);
      carousel.render({
        elem: this
        ,width: '100%'
        ,arrow: 'none'
        ,interval: othis.data('interval')
        ,autoplay: othis.data('autoplay') === true
        ,trigger: (device.ios || device.android) ? 'click' : 'hover'
        ,anim: othis.data('anim')
      });
    });
    
    element.render('progress');

    saleChart.init();
    numberChart.init();
    monthChart.init();
    channelChart.init();

  });
  
  exports('console', {})
});